package operation;

import data.DataBase;

public class CheckEnter implements IOperation {
    @Override
    public void work(DataBase dataBase) {
        System.out.println("样本检测结果录入！");
        System.out.print("请输入手机尾号后四位：");
        String temPhone = scanner.nextLine();

        int currentSize=dataBase.getContainSize();
        for (int i = 0; i < currentSize; i++) {
            String splitPhone = dataBase.getData(i).getPhone().substring(dataBase.getData(i).getPhone().length()-4);
            if (temPhone.equals(splitPhone)) {
                dataBase.getData(i).setChecked(true);
                System.out.println("请输入检测结果:(1.阴性 2.阳性)");
                int choice = scanner.nextInt();
                scanner.nextLine();//读取回车符号
                if(choice==2) {
                    dataBase.getData(i).setNegative(true);
                }
                System.out.println("手机尾号为"+splitPhone+" 的居民检测结果录入完毕！");
                return;
            }
        }
        System.out.println("未找到尾号为"+temPhone+"的采样信息，检测失败!");
    }
}
